#include "detectionAssist.h"  
#include "signalLamp.h"
 //检测辅助函数库

int bijiao(int zi)
{
    if(zi==NO) {return 0;}
    else if(zi==YES) {return 1;}
    else {printf("接收出错。\n"); return 2;}
}

//检测函数 用来给服务传送手机号消息,相同返回1也就是yes
int Detection(BUF *tmpbuf)
{
    USERMES *usermes=(USERMES*)tmpbuf->buf;
    //no不存在 yes存在
    char pd[MES_BUF_SIZE];
    if(tmpbuf->choice==INQUIRE)
    {
        printf("请输入你的手机号：\n");
        scanf("%s",usermes->PhoneNumber);
        getchar();
        write(SERVERFD,tmpbuf,sizeof(BUF));
        read(SERVERFD,tmpbuf,sizeof(BUF));
        return bijiao((int)tmpbuf->choice);
    }
    else if(tmpbuf->choice==LOGIN)
    {
        write(SERVERFD,tmpbuf,sizeof(BUF));
        read(SERVERFD,tmpbuf,sizeof(BUF));
        return bijiao((int)tmpbuf->choice);
    }
    else if(tmpbuf->choice=FINDACCOUNT)
    {
        write(SERVERFD,tmpbuf,sizeof(BUF));
        read(SERVERFD,tmpbuf,sizeof(BUF));
        return bijiao((int)tmpbuf->choice);
    }
}
